package com.book.modules.configure;

import feign.Logger;
import feign.Request;
import feign.Retryer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import static java.util.concurrent.TimeUnit.SECONDS;

/**
 * Description：
 *
 * @Author： leo.xiong
 * @CreateDate： 2020/12/03 15:36
 * @Email： leo.xiong@suyun360.com
 * @Since：
 */
@Configuration
public class FeignConfig {


    /**
     * 配置请求重试
     */
    @Bean
    public Retryer feignRetryer() {
        return new Retryer.Default(200, SECONDS.toMillis(2), 10);
    }


    /**
     * 设置请求超时时间
     * 默认
     * public Options() {
     * this(10 * 1000, 60 * 1000);
     * }
     */
    @Bean
    Request.Options feignOptions() {
        return new Request.Options(60 * 1000, 60 * 1000);
    }


    /**
     * 打印请求日志
     *
     * @return
     */
    @Bean
    public Logger.Level multipartLoggerLevel() {
        return feign.Logger.Level.FULL;
    }

}
